package cn.qvtu.game.model;

import cn.qvtu.game.util.StaticValue;

import java.awt.image.BufferedImage;
import java.util.ArrayList;
import java.util.List;

public class BackGround {
    // 显示场景图片
    private BufferedImage showImage = null;
    // 序号
    private int sort = 0;
    // 下一个场景序号
    private int nextSort = 0;
    // 敌人
    private List<Enemy> enemyList = new ArrayList<>();

    public  BackGround(int sort){
        this.sort = sort;
        create();
    }
    public void create(){
        switch (sort){
            case 1:
                this.showImage = StaticValue.bg01;
                this.enemyList.add(new Enemy(600,145,this));
                this.enemyList.add(new Enemy(400,145,this));
                this.enemyList.add(new Enemy(200,145,this));
                this.nextSort = 2;
                break;
            case 2:
                this.showImage = StaticValue.bg02;
                this.enemyList.add(new Enemy(600,145,this));
                this.enemyList.add(new Enemy(400,145,this));
                this.enemyList.add(new Enemy(200,145,this));
                this.nextSort = 3;
                break;
            case 3:
                this.showImage = StaticValue.bg03;
                this.enemyList.add(new Enemy(600,145,this));
                this.enemyList.add(new Enemy(400,145,this));
                this.enemyList.add(new Enemy(200,145,this));
                this.enemyList.add(new Enemy(100,145,this));
                this.nextSort = 4;
                break;
            case 4:
                this.showImage = StaticValue.bg04;
                this.enemyList.add(new Enemy(600,145,this));
                this.enemyList.add(new Enemy(400,145,this));
                this.enemyList.add(new Enemy(200,145,this));
                this.enemyList.add(new Enemy(100,145,this));
                this.nextSort = 1;
                break;
            default:
                break;
        }
    }

    // 是否有下一个场景
    public boolean hasNext(){
        return this.nextSort!= 0;
    }

    // 创建下一个场景
    public BackGround next(){
        return new BackGround(this.nextSort);
    }

    // 是否可以通过
    public boolean isPass(Person person){
        if (person.getX() >= 750){
            return true;
        }
        return false;
    }

    public BufferedImage getShowImage() {
        return showImage;
    }

    public void setShowImage(BufferedImage showImage) {
        this.showImage = showImage;
    }

    public List<Enemy> getEnemyList() {
        return enemyList;
    }

    public void setEnemyList(List<Enemy> enemyList) {
        this.enemyList = enemyList;
    }
}
